package test;

public class ProgressBar {
    public static void printProgress(String name,int progress, int total) {
        // 生成进度条
        int percent = progress * 100 / total;
        String format = "\r%s: %3d%%";
        System.out.printf(format, name, percent);
    }

    public static void main(String[] args) throws InterruptedException {
        int total = 100;
        for (int i = 0; i <= total; i++) {
            printProgress("",i, total);
            Thread.sleep(100);  // 模拟耗时操作
        }
    }
}
